package com.wesley.consumer.controller;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.client.RestTemplate;

/**
 * <h1> 消费者 </h1>
 *
 * @author Wesley.Wei
 * @date 2024-04-24 5:08 下午
 */
@RestController
@RequestMapping("/test")
public class ConsumerController {

  private final RestTemplate restTemplate;

  @Autowired
  public ConsumerController(RestTemplate restTemplate) {this.restTemplate = restTemplate;}

  @GetMapping("/hello/{name}")
  public String hello(@PathVariable String name) {
    return restTemplate.getForObject("http://provider/test/hello/" + name, String.class);
  }


}